﻿using System;
using Avalonia.Data.Converters;
using Avalonia.Media;

namespace Klear.Converters;

public class BoolToColorConverter : IValueConverter
{
    //public static readonly BoolToColorConverter Instance  = new BoolToColorConverter();

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value is bool && (bool)value)
        {
            return new SolidColorBrush(Colors.Red); // 超过阈值时显示红色
        }
        return new SolidColorBrush(Colors.Green); // 未超过阈值时显示绿色
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}